﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="PersonDetailsView.ascx.cs" Inherits="Administration_Views_PersonDetailsView" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxControlToolkit" %>
<%@ Register TagPrefix="spring" Namespace="Spring.Web.UI.Controls" Assembly="Spring.Web" %>

<spring:DataBindingPanel ID="dataBindingPanel" runat="server">
    <table>
        <tr>
            <td class="detailsFormHeader">
                Personal Info
            </td>
        </tr>
        <tr>
            <td>
                <table>
                    <tr>                        
                        <td class="detailsFormLabel">
                            <asp:Label ID="Label1" Text="Name:" runat="server" />
                        </td>
                        <td class="detailsFormValue">
                            <asp:TextBox ID="idTextBox" BindingTarget="Person.Id" Visible="false" runat="server" />
                            <asp:TextBox ID="nameTextBox" BindingTarget="Person.Name"  CssClass="detailsFormTextBox" runat="server" />
                            <asp:RequiredFieldValidator ID="nameRequiredFieldValidator" ControlToValidate="nameTextBox" Display="None" 
                                                        ErrorMessage="Name is required" runat="server" />
                            <ajaxControlToolkit:ValidatorCalloutExtender ID="nameRequiredValidatorCalloutExtender" HighlightCssClass="highlightValidatorCallout" 
                                                                         TargetControlID="nameRequiredFieldValidator"   
                                                                         runat="server" />                         
                        </td>                                                   
                    </tr>
                    <tr>
                        <td class="detailsFormLabel">
                            <asp:Label ID="Label2" Text="Surname:" runat="server" />
                        </td>                        
                        <td class="detailsFormValue">
                            <asp:TextBox ID="surnameTextBox" BindingTarget="Person.Surname" CssClass="detailsFormTextBox" runat="server" />
                            <asp:RequiredFieldValidator ID="surnameRequiredFieldValidator" ControlToValidate="surnameTextBox" Display="None" 
                                                        ErrorMessage="Surname is required" runat="server" />
                            <ajaxControlToolkit:ValidatorCalloutExtender ID="surnameRequiredValidatorCalloutExtender" HighlightCssClass="highlightValidatorCallout" 
                                                                         TargetControlID="surnameRequiredFieldValidator"  
                                                                         runat="server" />                                
                        </td>                                                                     
                    </tr>
                    <tr>
                        <td class="detailsFormLabel">
                            <asp:Label ID="Label3" Text="Login:" runat="server" />
                        </td>
                        <td class="detailsFormValue">                        
                            <asp:TextBox ID="loginTextBox" BindingTarget="Person.Login" CssClass="detailsFormTextBox" runat="server" />
                            <asp:RequiredFieldValidator ID="loginRequiredFieldValidator" ControlToValidate="loginTextBox" Display="None" 
                                                        ErrorMessage="Login is required" runat="server" />
                            <ajaxControlToolkit:ValidatorCalloutExtender ID="loginRequiredValidatorCalloutExtender1" 
                                                                         TargetControlID="loginRequiredFieldValidator"  
                                                                         runat="server" />                                 
                        </td>
                    </tr>
                    <tr>
                        <td class="detailsFormLabel">
                            <asp:Label ID="Label4" Text="Email:" runat="server" />
                        </td>                        
                        <td class="detailsFormValue">
                            <asp:TextBox ID="emailTextBox" BindingTarget="Person.Email" CssClass="detailsFormTextBox" runat="server" />
                            <asp:RegularExpressionValidator ID="emailRegularExpressionValidator" ControlToValidate="emailTextBox" Display="None"                                      
                                                            ValidationExpression="^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$" ErrorMessage="Invalid email address" runat="server" />    
                            <ajaxControlToolkit:ValidatorCalloutExtender ID="emailValidatorCalloutExtender"  HighlightCssClass="highlightValidatorCallout"
                                                                         TargetControlID="emailRegularExpressionValidator"  
                                                                         runat="server" />
                            <asp:RequiredFieldValidator ID="emailRequiredFieldValidator" ControlToValidate="emailTextBox" Display="None"
                                                        ErrorMessage="Email is required" runat="server" />
                            <ajaxControlToolkit:ValidatorCalloutExtender ID="emailRequiredValidatorCalloutExtender" HighlightCssClass="highlightValidatorCallout"
                                                                         TargetControlID="emailRequiredFieldValidator" runat="server" />                                                                         
                        </td>                                                                                             
                    </tr>                                                             
                    <tr>
                        <td class="detailsFormLabel">
                            <asp:Label ID="Label8" Text="Status:" runat="server" />
                        </td>                        
                        <td class="detailsFormValue">
                            <asp:Label ID="statusCodeLabel" BindingTarget="Person.StatusCode" BindingSource="Text" runat="server" />
                            <asp:Label Text=" since " runat="server" />
                            <asp:Label ID="statusDateLabel" BindingTarget="Person.StatusDate" BindingSource="Text" runat="server" />
                        </td>
                    </tr>
                </table>                                                             
            </td>
        </tr>                                                                                      
        <tr>
            <td class="detailsFormHeader">
                Played Role
            </td>
        </tr>
        <tr>
            <td>
                <table>
                    <tr>
                        <td class="detailsFormLabel">
                            <asp:Label ID="Label5" Text="Role:" runat="server" />
                        </td>
                        <td class="detailsFormValue">
                            <spring:RadioButtonGroup ID="roleCodeRadioButtonGroup" BindingTarget="PlayedRole.RoleCode" runat="server">
                                <asp:RadioButton ID="operational" Text="Operational" runat="server" />
                                <asp:RadioButton ID="administrator" Text="Administrator" runat="server" />
                                <asp:RadioButton ID="external_operational" Text="External tool" runat="server" />
                            </spring:RadioButtonGroup>   
                        </td>
                    </tr>
                    <tr>
                        <td class="detailsFormLabel">
                            <asp:Label ID="Label6" Text="Start date:" runat="server" />
                        </td>
                        <td class="detailsFormValue">
                            <asp:TextBox ID="startDateTextBox" CssClass="detailsFormTextBox" 
                                         BindingTarget="PlayedRole.StartDate" BindingFormatter="DateTimeFormatter" runat="server" />
                            <ajaxControlToolkit:CalendarExtender ID="startDateCalendarExtender" Format="yyyy/MM/dd"
                                                                 TargetControlID="startDateTextBox"
                                                                 runat="server" />
                            <asp:RequiredFieldValidator ID="startDateRequiredFieldValidator" ControlToValidate="startDateTextBox"
                                                        ErrorMessage="Role start date is required" Display="None" runat="server" />    
                            <ajaxControlToolkit:ValidatorCalloutExtender ID="startDateRequiredValidatorCalloutExtender" HighlightCssClass="highlightValidatorCallout"
                                                                         TargetControlID="startDateRequiredFieldValidator" runat="server" />
                            <asp:RegularExpressionValidator ID="startDateRegularExpressionValidator" ControlToValidate="startDateTextBox"
                                                            ValidationExpression="^([2][0]\d{2}\/([0]\d|[1][0-2])\/([0-2]\d|[3][0-1]))$|^([2][0]\d{2}\/([0]\d|[1][0-2])\/([0-2]\d|[3][0-1])\s([0-1]\d|[2][0-3])\:[0-5]\d\:[0-5]\d)$"
                                                            ErrorMessage="Valid date format is yyyy/MM/dd [HH:mm:ss]" Display="None" runat="server" />                                                                                                                                                                                              
                            <ajaxControlToolkit:ValidatorCalloutExtender ID="startDateREValidatorCalloutExtender" HighlightCssClass="highlightValidatorCallout"
                                                                         TargetControlID="startDateRegularExpressionValidator" runat="server" />                                                        
                        </td>
                    </tr>
                    <tr>
                        <td class="detailsFormLabel">
                            <asp:Label ID="Label7" Text="End date:" runat="server" />
                        </td>
                        <td class="detailsFormValue">
                            <asp:TextBox ID="endDateTextBox" CssClass="detailsFormTextBox" 
                                         BindingTarget="PlayedRole.EndDate" BindingFormatter="DateTimeFormatter" runat="server" />
                            <ajaxControlToolkit:CalendarExtender ID="endDateCalendarExtender" Format="yyyy/MM/dd" 
                                                                 TargetControlID="endDateTextBox"
                                                                 runat="server" />
                            <asp:RequiredFieldValidator ID="endDateRequiredFieldValidator" ControlToValidate="endDateTextBox" Display="None"
                                                        ErrorMessage="Role end date is required" runat="server" />
                            <ajaxControlToolkit:ValidatorCalloutExtender ID="endDateRequiredValidatorCalloutExtender" HighlightCssClass="highlightValidatorCallout"
                                                                         TargetControlID="endDateRequiredFieldValidator" runat="server" /> 
                            <asp:RegularExpressionValidator ID="endDateRegularExpressionValidator" ControlToValidate="endDateTextBox"
                                                            ValidationExpression="^([2][0]\d{2}\/([0]\d|[1][0-2])\/([0-2]\d|[3][0-1]))$|^([2][0]\d{2}\/([0]\d|[1][0-2])\/([0-2]\d|[3][0-1])\s([0-1]\d|[2][0-3])\:[0-5]\d\:[0-5]\d)$"
                                                            ErrorMessage="Valid date format is yyyy/MM/dd [HH:mm:ss]" Display="None" runat="server" />                                                                                                                                                                                              
                            <ajaxControlToolkit:ValidatorCalloutExtender ID="endDateREValidatorCalloutExtender"  HighlightCssClass="highlightValidatorCallout"
                                                                         TargetControlID="endDateRegularExpressionValidator" runat="server" />                                                                          
                        </td>
                    </tr>
                </table>
            </td>                            
        </tr>                        
    </table>              
    <asp:Panel CssClass="detailsFormCommandPanel" runat="server">
        <asp:LinkButton ID="returnLinkButton" Text="Return" OnClick="returnLinkButton_Click"
                        BindingTarget="ReturnViewName != null" BindingSource="Visible" BindingDirection="TargetToSource" runat="server" />
        <asp:LinkButton ID="updateLinkButton" Text="Update" OnClick="saveLinkButton_Click" runat="server" />                                                                        
        <asp:LinkButton ID="activateLinkButton" Text="Activate" OnClick="activateLinkButton_Click"
                        BindingTarget="Person.StatusCode == 'disabled'" BindingSource="Visible" BindingDirection="TargetToSource" runat="server" />
        <asp:LinkButton ID="setPasswordLinkButton" Text="Set password and activate" OnClick="setPasswordLinkButton_Click"
                        BindingTarget="Person.StatusCode == 'registered'" BindingSource="Visible" BindingDirection="TargetToSource" runat="server" />
        <asp:LinkButton ID="disableLinkButton" Text="Disable" OnClick="disableLinkButton_Click"
                        BindingTarget="Person.StatusCode == 'active'" BindingSource="Visible" BindingDirection="TargetToSource" runat="server" />
        <asp:LinkButton ID="changePasswordLabel" Text="Change password" OnClick="changePasswordLinkButton_Click"
                        BindingTarget="Person.StatusCode != 'registered'" BindingSource="Visible" BindingDirection="TargetToSource" runat="server" />                        
    </asp:Panel>                    
    <br />                    
</spring:DataBindingPanel>